﻿// Services/NotificationService.cs
using _111.QywxDocument.Model;
using _111.QywxDocument.WeeklyReport.Model;
using MyDapperApi.Services;
using MyDapperApi.Services.ConsumerNum;
using MyDapperApi.Services.QywxDocument.DigitalizationDemand;
using MyDapperApi.Services.QywxDocument.WeeklyReport;
using System.Threading.Tasks;

public class NotificationService
{
    private readonly IAutoNetUpdateService _autoNetUpdateService;
    private readonly IDocDigitalizationDemandService _docDigitalizationDemandService;
    private readonly IDocWeeklyReportService _docWeeklyReportService;
    private readonly IConsumerNumService _consumerNumService;

    // 通过依赖注入获取配置，从而读取连接字符串
    public NotificationService(IAutoNetUpdateService autoNetUpdateService,
        IDocDigitalizationDemandService docDigitalizationDemandService,
        IDocWeeklyReportService docWeeklyReportService,
        IConsumerNumService consumerNumService)
    {
        _autoNetUpdateService = autoNetUpdateService;
        _docDigitalizationDemandService = docDigitalizationDemandService;
        _docWeeklyReportService = docWeeklyReportService;
        _consumerNumService = consumerNumService;
    }
    /// <summary>
    /// 自动更新客流量
    /// </summary>
    /// <returns></returns>
    public async Task ISendPendingNotifications()
    {
        await _autoNetUpdateService.AutoUpdateQywxByRole();
    }

    public async Task IClearDocDigitalizationDemandService()
    {
        await _docDigitalizationDemandService.ClearDataBaseDigitalizationDemand();
    }

    public async Task IUpdateWeeklyReport()
    {
        await _docWeeklyReportService.UpdateDataBaseWeeklyReport(new UpdateDocumentRequest() { cursor = 0, limit = 100, dateTime = DateTime.Now });
    }

    public async Task IUpdateConsumerNum(DateTime dateTime)
    {
        await _consumerNumService.UpdateConsumerNum(dateTime, "xshqs04", "09a85fa1-baef-44fd-91e4-cb3339ab802d");//武汉曲水
        await _consumerNumService.UpdateConsumerNum(dateTime, "xshqs06", "b6d9b1dd-c429-4f48-bc47-c0f30d003a51");//上海曲水
        await _consumerNumService.UpdateConsumerNum(dateTime, "xshqs05", "65a45a58-14a4-4951-b2cb-7cc183edcc83");//苏州曲水
        await _consumerNumService.UpdateConsumerNum(dateTime, "xshqs02", "418efe5f-6dc5-4075-b9c4-9a3c64be7830");//武汉曲水徐东
        await _consumerNumService.UpdateConsumerNum(dateTime, "xshqs01", "3394d868-b64f-4666-b6a2-2a62205e06c6");//北京曲水
    }
}